package com.novellotus.iov.carvice.activity;

import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

import com.jakewharton.rxbinding2.widget.RxTextView;
import com.novellotus.httploadingview.LoadingView;
import com.novellotus.iov.carvice.R;
import com.novellotus.iov.carvice.adapter.DiagnosisListAdapter;
import com.novellotus.iov.carvice.bean.RxDiagnosisListItem;
import com.novellotus.iov.carvice.retrofit.BaseEntity;
import com.novellotus.iov.carvice.retrofit.BaseObserver;
import com.novellotus.iov.carvice.retrofit.RetrofitFactory;
import com.novellotus.iov.carvice.retrofit.RxSchedulers;
import com.novellotus.iov.carvice.rxjava.MyObserver;
import com.novellotus.iov.carvice.utils.MyViewUtils;
import com.novellotus.iov.carvice.utils.SharedPreferencesUtils;
import com.novellotus.iov.carvice.view.PageView;
import com.orangegangsters.github.swipyrefreshlayout.library.RefreshLayout;
import com.orangegangsters.github.swipyrefreshlayout.library.RefreshLayoutDirection;

import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.Observable;

public class DiagnosisListActivity extends BaseActivity {
    @BindView(R.id.tv_tittle)
    TextView tv_tittle;
    private String eCode, rCode;
    DiagnosisListAdapter diagnosisListAdapter;

    private final int PAGE_SIZE = 10;
    private String time;

    @Override
    protected void initContentView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_diagnosis_list);
    }

    @Override
    public void init() {
        eCode = getIntent().getStringExtra("eCode");
        rCode = getIntent().getStringExtra("rCode");
        getList(1, PAGE_SIZE);
        tv_tittle.setText("自动化诊断");
//        pageView.refreshLayout.setOnRefreshListener(this);
//        pageView.setPageViewInterface(this);
//        pageView.setReLoadBtnListener(this);
//        diagnosisListAdapter = new DiagnosisListAdapter(null, DiagnosisListActivity.this);
//        pageView.setBottomInterface(diagnosisListAdapter);
//        pageView.setRecyclerViewAdapter(MyViewUtils.getLinearLayoutManager(DiagnosisListActivity.this), diagnosisListAdapter);
    }

    @OnClick(R.id.img_back)
    void back() {
        finish();
    }


    /**
     * 获取车辆列表
     */
    public void getList(int current, int size) {
//        Observable<BaseEntity<RxDiagnosisListItem>> observable = RetrofitFactory.getInstance().getDiagnoseList(SharedPreferencesUtils.getKey(this)[0], eCode, rCode, size, current, edt_search.getText().toString());
//        observable.compose(RxSchedulers.<BaseEntity<RxDiagnosisListItem>>compose())
//                .subscribe(new BaseObserver<RxDiagnosisListItem>(this) {
//
//                    @Override
//                    public void onSuccess(RxDiagnosisListItem rxDiagnosisListItem) {
//                        pageView.loadSuccess();
//                        if (rxDiagnosisListItem != null && rxDiagnosisListItem.getRecords() != null && rxDiagnosisListItem.getRecords().size() > 0) {
//                            pageView.setTotalPage(rxDiagnosisListItem.getTotal(), PAGE_SIZE);
//                            if (rxDiagnosisListItem.getCurrent() == 1) {
//                                diagnosisListAdapter.updateList(rxDiagnosisListItem.getRecords());
//                            } else {
//                                diagnosisListAdapter.addList(rxDiagnosisListItem.getRecords());
//                            }
//                        } else {
//                            pageView.loadFail("无相关数据", false);
//                        }
//
//                    }
//
//                    @Override
//                    public void onFail(int code, String msg) {
//
//                    }
//
//                    @Override
//                    public void onError(String msg) {
//                    }
//                });
    }


//    @Override
//    public void clickDiagnosis(String plate, String vin) {
//        Bundle bundle = new Bundle();
//        bundle.putString("vin", vin);
//        bundle.putString("e", eCode);
//        bundle.putString("r", rCode);
//        bundle.putString("time", time);
//        openActivity(DiagnosisActivity.class, bundle);
//    }
}
